# -*- coding: utf-8 -*-
# @Time    : 2021/4/14 18:35
# @Author  : Zhangrenjie
# @Email   : zhangrenjie1998@163.com
# @File    : zhangrenjie.py
# @Software: PyCharm
import random
import string



# 判断用户输入
def check_input(number):
    """

    :param number: 传入参数
    :return: 返回判断类型
    """
    return number in string.digits


# 生成激活码
def create_code(n: int):
    """

    :param n: 传入参数激活码生成的个数
    :return: 返回一个装着激活码的列表
    """
    code_list = []
    for i in range(n):
        code_list.append(''.join(random.choices(string.ascii_uppercase+string.digits, k=32)))
    return code_list


# 激活码的文件写入
def write_file(filename, contents):
    """

    :param filename:文件名
    :param contents:文本内容
    """
    with open(filename, 'w+', encoding='utf-8') as f:
        for item in contents:
            f.write(f'{item}\n')